Sorry, the browser you are using is not currently supported. Disqus actively supports the following browsers:
This page is forcing your browser to use legacy mode, which is not compatible with Disqus. Please see our troubleshooting guide to get more information about this error.
"I have a lot of failures. The key is to fail quickly, not to avoid failing. I need to not get discouraged."
This is the key insight to success in any creative endeavor. Entrepreneurs learn it early or are never heard from again.
Sometimes I need to remind myself of this :)
awesome, i would like just render the world map generated with 2D sprites :) How i can map polygone with sprite.
Thank you for your help
Maybe i could work on the bitmap generated and consider each point of the bitmap being a tile according its color mapped to biomes list ... It's not elegant but it could work ... ?
Hi Luc: what I've done in the past is render the polygons to a bitmap, and then turn each bitmap into a tile according to the biome list. You can treat each tile as a sprite if that's convenient for you, or you can render multiple tiles into a single sprite.
wow it's really amazing!
Thank you very much for this thorough tutorial. I found that the maps I generated via perlin noise to be unsuited for my own game; this method should be excellent though.
I noticed that you weren't able to completely fill in the polygons on the outermost edges of the graph. (mapgen2.renderPolygons) You were able to circumvent that issue by just filling with blue before drawing anything, which works since you force the outer edges to be water.
I'd like to share my code that draws the outer polygons. Hopefully it will be of use to someone. Note it is in Java.
https://gist.github.com/Hoten/...
There is only one small issue which arises with a low number of sites. See comments. But with >10, it works perfectly!
Again, thank you very much for this. I will be blogging about how I will utilize these methods to create interesting worlds for my 'persistent morpg'. If you wish to check it out, keep an eye on my blog! (blog.hotengames.com)
Hi Hoten, yes, I used a hack for the outermost edge but it'd be nicer to do it properly. :) Thanks for sharing your code for that!
Hello. There seems to be one thing that is very simple which I can't seem to understand. You defined the moisture as distance from water. So since the ocean is entirely water, the edges of the map should be very moisturized. (Although it makes sense to have it be sandy or desertlike). I am able to understand the first diagram in the river section, where I assume that the greener areas are more moisturized. However, once you get to the biome section, the coasts seem to be dry like the subtropical desert area of your biome diagram, although I thought that they were the most moist. When you do this, the map seems to make sense realistically (as in beaches on the coast) but I am unable to figure out how that relates to the high moisture level. What causes the moist coastal regions to show up as dry desert-like areas, or am I mistaken? Thanks!
Hi Bloeg, yes, good question. On land, moisture is distance from fresh water (rivers and lakes) but not salt water (oceans). On the coast and in oceans, the moisture is set to the maximum, but this is never used. The biome assignment on the coastal polygons and all ocean polygons ignores the moisture value. Beyond that first coastal polygon, you see deserts because they are far from rivers or lakes.
I also am confused about another thing. How on earth does your water/land decider (that decides whether a polygon is water or land) work? I mean what does it do!? I looked at the code and it works but it makes no sense. Thanks!
Hi Bloeg, the functions in the IslandShape class decide what's water and what's land. They take a point in the range x=(-1, +1), y=(-1, +1) and return true or false. The simplest one is makeSquare, which always returns true (land) and never false (water). The next simplest is makeBlob, which returns true if the distance from the origin is less than some factor. You can see what that looks like here (there's an extra bit for the eyes but ignore that for now).
You can make it do whatever you want. If you want it to be a smiley face or a kitten or any shape, you just have to write a function that returns true or false if it's land or water. For example you could load a bitmap and have it return the colors from that.
I had good luck with "natural" looking shapes with the radial function (which is a mess) and the perlin noise function. Perlin noise is often used for map generation. It just generates lots of hills and valleys. Everything above some threshold I considered land; everything below is water.
This is extremely impressive, I have three things to ask. First would you be ok with me using the demo to create an island that would be used as concept art for an animation project I am currently planning? Second with the demo can it only generate random maps or can I generate a map then tweak it as well? Third what can the map be exported as? BMP? JPEG?
Again very impressive work, keep it up :-)
Absolutely, feel free to use the demo and code! The demo only generates random maps but the code is designed to run in multiple stages, allowing tweaking at any stage (this is merely the design — I have not actually implemented any tweaking abilities). The demo exports as XML but the code can also export the moisture/elevation arrays. The easiest thing for now if you want bitmap output is to take a screenshot. If you want to dig into the code, look at the makeExport function (which generates a 2048x2048 bitmap internally) and have it export to a high resolution PNG/BMP instead of to an array.
weeee nice
Your AS3 project in Github throws runtime errors when generating. I am using ASC2.0, could this be it?
Hi rNd, that could be. I haven't tried ASC2.0. Could you describe the errors, or email them to me at redblobgames@gmail.com ? Thanks!
Really really love this. Some great food for thought and the results look fantastic in your demo!
Thanks very much for sharing this :)
This is just awesome. I am working on a 2d side scrolling game which could use this by taking a vertical slice of the "3d slopes" render. i looked into
Delaunay triangles, do you have any other advice?
My main advice is to start with what features you want for gameplay, and find a technique that generates maps you need, instead of the other way around. :) You might also find this paper to be useful: http://www.doc.ic.ac.uk/~sgc/p...
Really cool! It's not directly useful for my current project, but I can still learn a lot from this stuff. Thanks!
Hi! I tried out the trial for this and I love it! Would you mind if I use the map I like in a story I'm writing?
Feel free! The demo was meant to show what the algorithm can do if you incorporate it into your own game, but some people are using it for maps that aren't in games.
Thanks so much!!!
Hi amitp, can I use the maps generated by your program in our game? We are students and in a team of 4 participating in the MS Imagine Cup competition.
We will state the credits to u. Thank you.
Yes, absolutely! You can either export the maps (XML format in this demo, or 2048x2048 array format in the version I just posted to my blog), or you can use the source code directly (MIT open source license).
Now...how do I get a gif copy of that animated image >.>;
Which animated image? Do you mean the Flash demo? If so, I don't have an image export yet but it's something I'll add the next time I work on this.
Excellent! Can I use it for my kids in class? Link? Great work!
Yes, feel free to use this in your class. Also, the code is open source (MIT licensed) so you can download it and incorporate it into your own projects.
woah man ! I'm just a beginner - intermediate flash game programmer. Must say 'Woah man !' One day I too will do these :)
I must say, an absolutely fantastic piece of landscape generation! Intuitive and natural, it has a real feel of fractal realism to it. Amazing.
hey amit this is (as you know) pretty the much coolest thing on the web... however in trying to port (some of) this to haxe I've run across a problem. You have this line: 'var vedge:LineSegment = libedge.voronoiEdge();' in your map generator but the voronoi library (which has been ported to haxe) doesn't seem to contain that method/property (neither does the as3 library). Did you add that function and what exactly is it?
I could most likely figure out how to get the edge but I'd rather port this directly without messing with a bunch of code I don't understand :P
Hi Dakasha! Sorry about that. I should make it more clear in the download — I had to make a change to the as3delaunay library. It had some data I needed, but marked it private, so I changed it to be public. You can find my modified version on github, and you can see that it's a small diff. I hope that you can use that diff to change the HaXe port. (BTW, is your HaXe port available online?)
No it is not (I haven't finished it.. I'm learning HaXe and as3 while doing this ;) )
I'm now really debating whether to actually port.. Unity3D's flash project is in beta and since I do plan on using unity in the future it may make more sense to just stick with pure as3 (since all code will be easily transferable). However HaXe is very interesting..
In any case I didn't have a direct port in mind. I plan on using some of your amazing methods to design my own MapGen. If and when I finish I will definitely be making it public and I will keep you updated.
Thanks for your comment and for the amazing article :)
ohhh wait if you mean the haxe port of as3delaunay it is here:
https://bitbucket.org/sledorze...
I did not do it and it is not a robust port (as it states itself). It may require a bit of work to get running correctly
Thanks for the pointer! I'm quite interested in switching my map generator to HaXe. :-)
Hey, thanks for sharing these great ideas. I ported the first steps to java and wrote a more detailed introduction in german (http://johannes-lerch.de/tutor.... You can find the code including two required dependencies for delaunay and clipping here: http://johannes-lerch.de/wp-co...
I'm currently doing some procedural stuff myself (http://www.flickr.com/photos/b..., so it's cool to see other folks doing the same.
Hey, thanks so much for this – I used to love drawing fantasy maps when I was younger – inventing worlds and the like, so I really got a kick out of reading about it.
~B☼
Great article I've been looking for something like this for a long time.
Excellent article !
I did a conversion of the demo to Processing (Java) that you can see here : http://www.openprocessing.org/...
Only a few changes, and made some corrections so that the surfaces of lakes are flat.
I now try to use some of the ideas to create interesting hexagonal maps, which is harder since the edge length are all the same. So far I am using Perlin Noise for height, and correcting so that rivers are possible.
Christophe, that's great! I love the step-through feature. For hexagonal maps, instead of using random points for the first step, you can place a grid of hexagonal centers (and skip the Lloyd relaxation step). I haven't tried this to see how the resulting maps look though.
Have you use which data structure? Winged-edge? Half-edge?
Hi Totonixsame, I ended up using an explicit graph representation based on what the as3delaunay library produced. It would've been great if it produced a winged edge data structure but it didn't. Instead, each edge is stored once, and I annotate it with pointers to the vertex and center Point objects. I also annotate the vertex and center objects with pointers to each other, as well as the edges they touch. See https://github.com/amitp/mapge...
Your research is spectacular. I'm going to try this on urban maps with procedural buildings generator. I'll let you know my results.
Regards.
I'd love to hear how it goes!
This is a great article and excellent demo!
Keep up the cool work! :-)
The only criticism I have is about the lakes: the surfaces of lakes are flat, whereas the lake polygons this application is creating are not. You might want to adjust the algorithm to make all the polygons of a lake to all lie in the same plane (I realize that this would likely mess up with your river heuristic....)
Yes, this is a flaw with the lake algorithm. I was mostly going for top-down 2d games, where issues like this can be fudged, and tacked on the 3d view as an afterthought, but seeing the 3d view made me realize how messed up the lake boundaries are. A related problem is that there aren't any cliffs — the altitude function varies smoothly (the slope is near constant) and doesn't have the flatness for lakes nor the abrupt boundaries for cliffs (including steep canyon walls). To use these maps in a 3d game would require additional passes to adjust the elevation to make these kinds of features.
Thanks for the feedback!
Now I want to spot working on "real" apps for working people and start designing GAMES.
Oh man. Excellent article!